home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap18 / dun18_4.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  9.2 KB  |  244 lines

  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  2.  
  3. <html><head>
  4.  
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6.  
  7. <title>Baseball Cards</title></head>
  8.  
  9. <body bgcolor="#FFFFFF">
  10.  
  11. <p>
  12.  
  13. <object id="cards" ondatasetcomplete="dataloaded()"
  14.  
  15. classid="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83" width="192" height="192">
  16.  
  17.   <param name="DataURL" value="cards.txt">
  18.  
  19.   <param name="UseHeader" value="1">
  20.  
  21.   <param name="Sort" value="year; cardnumber">
  22.  
  23. </object>
  24.  
  25. </p>
  26.  
  27.  
  28.  
  29. <!-- START modified from Listing 18.3 -->
  30.  
  31. <h3 align="center">
  32.  
  33. To filter the data for a specific year, enter the year here and click the
  34.  
  35. Filter button:</h3>
  36.  
  37. <form id="filterform">
  38.  
  39.   <div align="center"><center><h3>Year:
  40.  
  41.      <input type="text" name="FilterYear" size="20"></h3>
  42.  
  43.   </center></div>
  44.  
  45.   <div align="center"><center><h3>
  46.  
  47.   <input type="submit" value="Filter" name="B1" onclick="filteryear(0)">
  48.  
  49.   <input type="reset" value="Reset" name="B2" onclick="filteryear(1)">
  50.  
  51.   </h3></center></div>
  52.  
  53. </form>
  54.  
  55. <hr>
  56.  
  57. <h3 align="center">Use any of these buttons to sort the data:</h3>
  58.  
  59. <p align="center"><input type="button" value="Year/Card Number" name="B1"
  60.  
  61. onclick="buttonclick(1)"><input type="button" value="Description" name="B2"
  62.  
  63. onclick="buttonclick(2)"><input type="button" value="Year/Grade" name="B3"
  64.  
  65. onclick="buttonclick(3)"><input type="button" value="Value" name="B4"
  66.  
  67. onclick="buttonclick(4)"></p>
  68.  
  69. <h3 align="center">Or, to sort by any column, click the column's header.</h3>
  70.  
  71. <hr>
  72.  
  73. <!-- END modified from Listing 18.3 -->
  74.  
  75.  
  76.  
  77. <table border="1" datasrc="#cards" align="center" cellpadding="2">
  78.  
  79. <THEAD>
  80.  
  81.   <tr>
  82.  
  83.     <td align="left" id="year" onclick="tableclick('year')"
  84.  
  85.         bgcolor="#00FFFF"><big>+Year</big></td>
  86.  
  87.     <td align="left" id="CardNumber" onclick="tableclick('cardnumber')"
  88.  
  89.         bgcolor="#00FFFF"><big>+Number</big></td>
  90.  
  91.     <td align="left" id="setname" onclick="tableclick('setname')"
  92.  
  93.         bgcolor="#00FFFF"><big>Set Name</big></td>
  94.  
  95.     <td align="left" id="issuer" onclick="tableclick('issuer')"
  96.  
  97.         bgcolor="#00FFFF"><big>Issuer</big></td>
  98.  
  99.     <td align="left" id="description" onclick="tableclick('description')"
  100.  
  101.         bgcolor="#00FFFF"><big>Description</big></td>
  102.  
  103.     <td align="left" id="grade" onclick="tableclick('grade')"
  104.  
  105.         bgcolor="#00FFFF"><big>Grade</big></td>
  106.  
  107.     <td align="right" id="value" onclick="tableclick('value')"
  108.  
  109.         bgcolor="#00FFFF"><big>Value</big></td>
  110.  
  111.   </tr>
  112.  
  113. </THEAD>
  114.  
  115.   <tr>
  116.  
  117.     <td><div datafld="year"></div></td>
  118.  
  119.     <td><div datafld="cardnumber"></div></td>
  120.  
  121.     <td><div datafld="setname"></div></td>
  122.  
  123.     <td><div datafld="issuer"></div></td>
  124.  
  125.     <td><div datafld="description"></div></td>
  126.  
  127.     <td><div datafld="grade"></div></td>
  128.  
  129.     <td width="50" align="right"><div datafld="value"></div></td>
  130.  
  131.   </tr>
  132.  
  133. <TFOOT>
  134.  
  135.   <tr>
  136.  
  137.     <td colspan="6" align="right" height="40" bgcolor="#000080">
  138.  
  139.     <font color="#FF0000" size="4"><strong>Total:</strong></font></td>
  140.  
  141.     <td valign="center" align="right" bgcolor="#000080">
  142.  
  143.     <font color="#FF0000" size="4">
  144.  
  145.     <strong><div id="TotalText"></div></strong></font></td>
  146.  
  147.   </tr>
  148.  
  149. </TFOOT>
  150.  
  151. </table>
  152.  
  153.  
  154.  
  155. <script language="VBScript"><!--
  156.  
  157. sub tableclick(columnname)
  158.  
  159.  
  160.  
  161. if columnname <> "year" and
  162.  
  163. cc]    (left(document.all.item("year").innertext,1) = "+"
  164.  
  165. cc]   or left(document.all.item("year").innertext,1) = "-") then
  166.  
  167.       document.all.item("year").innerHTML = "<big>" +
  168.  
  169. cc]         mid(document.all.item("year").innertext,2) + "</big>"
  170.  
  171. end if
  172.  
  173.  
  174.  
  175. if columnname <> "cardnumber" and
  176.  
  177. cc]   (left(document.all.item("cardnumber").innertext,1) = "+" or
  178.  
  179. cc]   left(document.all.item("cardnumber").innertext,1) = "-") then
  180.  
  181.       document.all.item("cardnumber").innerHTML = "<big>" +
  182.  
  183. cc]          mid(document.all.item("cardnumber").innertext,2) + "</big>"
  184.  
  185. end if
  186.  
  187.  
  188.  
  189. if columnname <> "setname" and
  190.  
  191. cc]  (left(document.all.item("setname").innertext,1) = "+" or
  192.  
  193. cc]  left(document.all.item("setname").innertext,1) = "-") then
  194.  
  195.     document.all.item("setname").innerHTML = "<big>" +
  196.  
  197. cc]        mid(document.all.item("setname").innertext,2) + "</big>"
  198.  
  199. end if
  200.  
  201.  
  202.  
  203. if columnname <> "issuer" and
  204.  
  205. cc]  (left(document.all.item("issuer").innertext,1) = "+" or
  206.  
  207. cc]   left(document.all.item("issuer").innertext,1) = "-") then
  208.  
  209.      document.all.item("issuer").innerHTML = "<big>" +
  210.  
  211. cc]       mid(document.all.item("issuer").innertext,2) + "</big>"
  212.  
  213. end if
  214.  
  215.  
  216.  
  217. if columnname <> "description" and
  218.  
  219. cc]  (left(document.all.item("description").innertext,1) = "+" or
  220.  
  221. cc]   left(document.all.item("description").innertext,1) = "-") then
  222.  
  223.      document.all.item("description").innerHTML = "<big>" +
  224.  
  225. cc]       mid(document.all.item("description").innertext,2) + "</big>"
  226.  
  227. end if
  228.  
  229.  
  230.  
  231. if columnname <> "grade" and
  232.  
  233. cc]  (left(document.all.item("grade").innertext,1) = "+" or
  234.  
  235. cc]   left(document.all.item("grade").innertext,1) = "-") then
  236.  
  237.      document.all.item("grade").innerHTML = "<big>" +
  238.  
  239. cc]       mid(document.all.item("grade").innertext,2) + "</big>"
  240.  
  241. end if
  242.  
  243.  
  244.  
  245. if columnname <> "value" and
  246.  
  247. cc]  (left(document.all.item("value").innertext,1) = "+" or
  248.  
  249. cc]   left(document.all.item("value").innertext,1) = "-") then
  250.  
  251.      document.all.item("value").innerHTML = "<big>" +
  252.  
  253. cc]       mid(document.all.item("value").innertext,2) + "</big>"
  254.  
  255. end if
  256.  
  257.  
  258.  
  259. if left(document.all.item(columnname).innertext,1) = "+" then
  260.  
  261.    document.all.item(columnname).innerHTML =  "<big>-" +
  262.  
  263. cc]     mid(document.all.item(columnname).innertext,2) + "</big>"
  264.  
  265.    cards.sort = "-" + columnname
  266.  
  267. elseif left(document.all.item(columnname).innertext,1) = "-" then
  268.  
  269.    document.all.item(columnname).innerHTML = "<big>+" +
  270.  
  271. cc]     mid(document.all.item(columnname).innertext,2) + "</big>"
  272.  
  273.    cards.sort = columnname
  274.  
  275. else
  276.  
  277.    document.all.item(columnname).innerHTML = "<big>+" +
  278.  
  279. cc]     document.all.item(columnname).innertext + "</big>"
  280.  
  281.    cards.sort = columnname
  282.  
  283. end if
  284.  
  285.  
  286.  
  287. cards.reset
  288.  
  289.  
  290.  
  291. end sub
  292.  
  293.  
  294.  
  295. sub buttonclick(button)
  296.  
  297.  
  298.  
  299. if (left(document.all.item("year").innertext,1) = "+" or
  300.  
  301. cc]  left(document.all.item("year").innertext,1) = "-") then
  302.  
  303.     document.all.item("year").innerHTML = "<big>" +
  304.  
  305. cc]       mid(document.all.item("year").innertext,2) + "</big>"
  306.  
  307. end if
  308.  
  309.  
  310.  
  311. if (left(document.all.item("cardnumber").innertext,1) = "+" or
  312.  
  313. cc]  left(document.all.item("cardnumber").innertext,1) = "-") then
  314.  
  315.     document.all.item("cardnumber").innerHTML = "<big>" +
  316.  
  317. cc]       mid(document.all.item("cardnumber").innertext,2) + "</big>"
  318.  
  319. end if
  320.  
  321.  
  322.  
  323. if (left(document.all.item("setname").innertext,1) = "+" or
  324.  
  325. cc]  left(document.all.item("setname").innertext,1) = "-") then
  326.  
  327.     document.all.item("setname").innerHTML = "<big>" +
  328.  
  329. cc]       mid(document.all.item("setname").innertext,2) + "</big>"
  330.  
  331. end if
  332.  
  333.  
  334.  
  335. if (left(document.all.item("issuer").innertext,1) = "+" or
  336.  
  337. cc]  left(document.all.item("issuer").innertext,1) = "-") then
  338.  
  339.     document.all.item("issuer").innerHTML = "<big>" +
  340.  
  341. cc]       mid(document.all.item("issuer").innertext,2) + "</big>"
  342.  
  343. end if
  344.  
  345.  
  346.  
  347. if (left(document.all.item("description").innertext,1) = "+" or
  348.  
  349. cc]  left(document.all.item("description").innertext,1) = "-") then
  350.  
  351.     document.all.item("description").innerHTML = "<big>" +
  352.  
  353. cc]       mid(document.all.item("description").innertext,2) + "</big>"
  354.  
  355. end if
  356.  
  357.  
  358.  
  359. if (left(document.all.item("grade").innertext,1) = "+" or
  360.  
  361. cc]  left(document.all.item("grade").innertext,1) = "-") then
  362.  
  363.     document.all.item("grade").innerHTML = "<big>" +
  364.  
  365. cc]       mid(document.all.item("grade").innertext,2) + "</big>"
  366.  
  367. end if
  368.  
  369.  
  370.  
  371. if (left(document.all.item("value").innertext,1) = "+" or
  372.  
  373. cc]  left(document.all.item("value").innertext,1) = "-") then
  374.  
  375.     document.all.item("value").innerHTML = "<big>" +
  376.  
  377. cc]       mid(document.all.item("value").innertext,2) + "</big>"
  378.  
  379. end if
  380.  
  381.  
  382.  
  383. select case button
  384.  
  385. case 1
  386.  
  387.    document.all.item("year").innerHTML = "<big>+" +
  388.  
  389. cc]             document.all.item("year").innertext + "</big>"
  390.  
  391.    document.all.item("cardnumber").innerHTML = "<big>+" +
  392.  
  393. cc]             document.all.item("cardnumber").innertext + "</big>"
  394.  
  395.    cards.sort = "year; cardnumber"
  396.  
  397. case 2
  398.  
  399.    document.all.item("description").innerHTML = "<big>+" +
  400.  
  401. cc]             document.all.item("description").innertext + "</big>"
  402.  
  403.     cards.sort = "description"
  404.  
  405. case 3
  406.  
  407.    document.all.item("year").innerHTML = "<big>+" +
  408.  
  409. cc]             document.all.item("year").innertext + "</big>"
  410.  
  411.    document.all.item("grade").innerHTML = "<big>+" +
  412.  
  413. cc]             document.all.item("grade").innertext + "</big>"
  414.  
  415.    cards.sort = "year; grade"
  416.  
  417. case 4
  418.  
  419.    document.all.item("value").innerHTML = "<big>+" +
  420.  
  421. cc]             document.all.item("value").innertext + "</big>"
  422.  
  423.    cards.sort = "value"
  424.  
  425. end select
  426.  
  427.  
  428.  
  429. cards.reset
  430.  
  431. end sub
  432.  
  433.  
  434.  
  435. <!-- START modified from Listing 18.3 -->
  436.  
  437. sub filteryear(reset)
  438.  
  439.  
  440.  
  441. if reset then
  442.  
  443.    fstring = ""
  444.  
  445. else
  446.  
  447.    fstring = "year = " + document.forms("filterform").item("filteryear").value
  448.  
  449. end if
  450.  
  451.  
  452.  
  453. cards.filter = fstring
  454.  
  455. cards.reset
  456.  
  457.  
  458.  
  459. end sub
  460.  
  461. <!-- END modified from Listing 18.3 -->
  462.  
  463.  
  464.  
  465. sub dataloaded()
  466.  
  467.  
  468.  
  469. while not(cards.recordset.eof)
  470.  
  471.    total = total + cards.recordset("value")
  472.  
  473.    cards.recordset.movenext
  474.  
  475. wend
  476.  
  477. document.all.totaltext.innertext = total
  478.  
  479.  
  480.  
  481. end sub
  482.  
  483. --></script>
  484.  
  485. </body></html>
  486.  
  487.